package com.chb.docter.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author: 陈海彬
 * @date: Created in 2023/11/2 11:57
 * @description: swagger文档配置文件
 * @modified By:
 * @version: 1.0
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket docket() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                //设置文档信息
                .apiInfo(apiInfo())
                //设置分组名称
                .groupName("第一组")
                .directModelSubstitute(Byte.class,Integer.class)
                //设置为哪些路径生产api文档
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.chb.docter.controller.apis"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                //标题
                .title("spring-boot测试系统")
                //描述
                .description("用于spring-boot+mybatis-plus+swagger2的基本使用以及注解")
                //许可
                .license("chb 2023-11-02")
                //许可链接
                .licenseUrl("https://www.baidu.com")
                //服务条款网址
                .termsOfServiceUrl("www.spring.io")
                //版本
                .version("1.0.1")
                //维护人员信息
                .contact(new Contact("陈海彬", "https://www.chb.com", "1834802437@qq.com"))
                .build();
    }
}